/**
 * Auto gen via dbpojo-gen.
 */
package com.us.usws.site.ipodium.action;

import java.util.List;

import javax.inject.Inject;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.us.usws.model.domain.userevent.EventFavVideo;
import com.us.usws.model.domain.userevent.EventShareVideo;
import com.us.usws.service.ro.UserEventROService;
import com.us.usws.site.ipodium.share.IpodiumPagination;
import com.us.usws.site.ipodium.share.Pagination;
import com.us.usws.support.uitls.SimpleDataPageUtil;
import com.us.usws.support.uitls.SiteWebContext;

/**
 * Struts2 action
 * @author robot
 */
public class UserEventVideoAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private static final int pageSize = 3;

	//private static Log log = LogFactory.getFactory().getInstance(EditProfileAction.class);

	@Inject
	UserEventROService roService;

	private int pageNo = 1;
	private List<EventFavVideo> favVideos;
	private List<EventShareVideo> shareVideos;
	private int pageCnt;

	private Pagination pg;

	/**
	 * load profile
	 * @return
	 */
	public String loadFavVidoes() {
		SiteWebContext swc = new SiteWebContext(ServletActionContext.getRequest(), ServletActionContext.getResponse());
		String uid = swc.getIpodiumUser().getUid();
		int rowCount = roService.getFavVideoCount(uid);
		SimpleDataPageUtil dpu = new SimpleDataPageUtil(pageSize, rowCount);
		dpu.setPageNo(pageNo);

		this.favVideos = roService.getFavVideos(uid, dpu.getStart(), pageSize);
		this.pageCnt = dpu.getPageCount();
		pg = new IpodiumPagination(pageNo, dpu.getPageCount(), "/ipodium/listFavVideos.action");

		return SUCCESS;
	}

	/**
	 * share videos
	 * @return
	 */
	public String loadShareVideos() {
		SiteWebContext swc = new SiteWebContext(ServletActionContext.getRequest(), ServletActionContext.getResponse());
		String uid = swc.getIpodiumUser().getUid();
		int rowCount = roService.getShareVideoCount(uid);
		SimpleDataPageUtil dpu = new SimpleDataPageUtil(pageSize, rowCount);
		dpu.setPageNo(pageNo);

		this.shareVideos = roService.getShareVideos(uid, dpu.getStart(), pageSize);
		this.pageCnt = dpu.getPageCount();
		pg = new IpodiumPagination(pageNo, dpu.getPageCount(), "/ipodium/listShareVideos.action");

		return SUCCESS;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public List<EventFavVideo> getFavVideos() {
		return favVideos;
	}

	public void setFavVideos(List<EventFavVideo> favVideos) {
		this.favVideos = favVideos;
	}

	public int getPageCnt() {
		return pageCnt;
	}

	public void setPageCnt(int pageCnt) {
		this.pageCnt = pageCnt;
	}

	public Pagination getPg() {
		return pg;
	}

	public void setPg(Pagination pg) {
		this.pg = pg;
	}

	public List<EventShareVideo> getShareVideos() {
		return shareVideos;
	}

	public void setShareVideos(List<EventShareVideo> shareVideos) {
		this.shareVideos = shareVideos;
	}

}